// ignore_for_file: deprecated_member_use

import 'package:get/get.dart';
import 'package:flutter/material.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:verse_systems/commom/config/config.dart';
import 'package:verse_systems/commom/global/global.dart';
import 'package:verse_systems/commom/provider/common_provider.dart';
import 'package:verse_systems/commom/routers/route_config.dart';
import 'package:verse_systems/messages.dart';
import 'package:verse_systems/res/colors.dart';
import 'package:provider/provider.dart';

class MzApp extends StatelessWidget {
  const MzApp({super.key, required this.initPage, required this.language});

  final String initPage;
  final String language;

  @override
  Widget build(BuildContext context) {
    return MultiProvider(
      providers: [
        ChangeNotifierProvider(create: (_) => CommonProvider()),
      ],
      child: ScreenUtilInit(
        designSize: const Size(375, 820),
        builder: (context, child) {
          return GetMaterialApp(
            translations: Messages(), // 翻译
            locale: Locale('zh', language), // 默认指定的语言翻译
            fallbackLocale: const Locale('zh', 'TW'),
            navigatorKey: Global.navigatorKey,
            debugShowCheckedModeBanner: false,
            title: Config.getConfigPage(),
            color: Colours.app_main_color,
            theme: ThemeData(backgroundColor: Colours.app_main_color),
            initialRoute: initPage,
            builder: EasyLoading.init(),
            getPages: RouteConfig.routes,
            defaultTransition: Transition.cupertino,
          );
        },
      ),
    );
  }
}
